//
//  ForgetPWDView.m
//  QRMaster
//
//  Created by myApple on 16/3/2.
//  Copyright © 2016年 myApple. All rights reserved.
//

#import "ForgetPWDView.h"
#import "LineView.h"
#import "PromptInfoView.h"
#import "validateInputValue.h"
#import "LineView.h"
#import "MyRsa.h"

@interface ForgetPWDView ()<UITextFieldDelegate>
{
    
    UILabel * typeLabel;
    UILabel * mobileLabel;
    UITextField * telePhoneField;
    UITextField * checkTextField;
    UITextField * newPWDTextField;
    
    LineView * telePhoneLineView;
    LineView * codeLineView;
    LineView * passWordLineView;
    
    UIButton * checkBtn;
    UIButton * newSeeBtn;
    UIImageView * newPWDView;
    UIButton * emailBtn;
    UIButton * mobileBtn;
    
    UIButton * mobileHeaderBtn;//手机账号前面可以点击的区号
    UILabel * emailHeaderLabel;//邮箱账号前面的显示
    NSInteger count;
    UIButton * nextBtn;
    
    BOOL mobileFlag;
    BOOL codeFlag;
    BOOL passwordFlag;
    
    NSString * mobileString;//电话号码输入的
    NSString * emailString;//邮箱输入的

}

@end

@implementation ForgetPWDView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    // Initialization code
        count = 0;
        mobileFlag = NO;
        codeFlag = NO;
        passwordFlag = NO;
        mobileString = nil;
        emailString = nil;
        [self prepareView];
    }
    return self;
}

-(void)prepareView
{
    float ScreenWidth = [UIScreen mainScreen].bounds.size.width;
    float width = 40;
    float height = 20;
    float x = 22;
    float y = 40;
    //类型
    typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height)];
    typeLabel.text = NSLocalizedString(@"type", nil);
    typeLabel.font = [UIFont systemFontOfSize:14.0];
    [self addSubview:typeLabel];
    
    // mobile
    x = 80;
    y = 20;
    width = 40;
    height = 40;
    UIImageView * mobileView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [self addSubview:mobileView];
    mobileView.userInteractionEnabled = YES;
    UITapGestureRecognizer * mobileTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(mobileClick)];
    [mobileView addGestureRecognizer:mobileTap];
    
    x = 10;
    y = 20;
    width = 20;
    height = 20;
    mobileBtn = [[UIButton alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [mobileBtn setBackgroundImage:[UIImage imageNamed:@"36_1"] forState:0];
    [mobileBtn setBackgroundImage:[UIImage imageNamed:@"36_2"] forState:UIControlStateSelected];
    [mobileBtn addTarget:self action:@selector(mobileClick) forControlEvents:UIControlEventTouchUpInside];
    mobileBtn.selected = YES;
    [mobileView addSubview:mobileBtn];
    
    x = 120;
    y = 40;
    width = 60;
    height = 20;
    mobileLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height)];
    mobileLabel.text =  NSLocalizedString(@"loginPromt", nil);
    mobileLabel.font = [UIFont systemFontOfSize:14.0];
    [self addSubview:mobileLabel];
    
    //email
    x = 180;
    y = 20;
    width = 40;
    height = 40;
    UIImageView * emailImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [self addSubview:emailImageView];
    emailImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer * emailTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(emailClick)];
    [emailImageView addGestureRecognizer:emailTap];
    
    x = 10;
    y = 20;
    width = 20;
    height = 20;
    emailBtn = [[UIButton alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [emailBtn setBackgroundImage:[UIImage imageNamed:@"36_1"] forState:0];
    [emailBtn setBackgroundImage:[UIImage imageNamed:@"36_2"] forState:UIControlStateSelected];
    [emailBtn addTarget:self action:@selector(emailClick) forControlEvents:UIControlEventTouchUpInside];
    [emailImageView addSubview:emailBtn];
    
    x = 220;
    height = 20;
    y = 40;
    UILabel * emailLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, 60, height)];
    emailLabel.text =  NSLocalizedString(@"mineEmail", nil);
    emailLabel.font = [UIFont systemFontOfSize:14.0];
    [self addSubview:emailLabel];
   
    //账号
    x = 80;
    y += height + 20;
    width = ScreenWidth - 20 - x;
    height = 40;
    telePhoneField = [[UITextField alloc]initWithFrame:CGRectMake(x, y, width, height)];
    telePhoneField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    telePhoneField.placeholder = NSLocalizedString(@"telePhoneNum", nil);
    telePhoneField.font = [UIFont systemFontOfSize:13.0];
    telePhoneField.borderStyle = UITextBorderStyleNone;
    telePhoneField.backgroundColor = [UIColor whiteColor];
    telePhoneField.delegate = self;
    telePhoneField.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self addSubview:telePhoneField];
    
    telePhoneLineView = [[LineView alloc]initWithFrame:CGRectMake(16, y + height, ScreenWidth - 32, 0.5)];
    telePhoneLineView.backgroundColor = UIColorFromRGB(0x7dc234);
    [self addSubview:telePhoneLineView];
    
    //前面点击的区号按钮
    x = 22;
    width = 80;
    mobileHeaderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    mobileHeaderBtn.frame = CGRectMake(x, y, width, height);
    [mobileHeaderBtn addTarget:self action:@selector(chooseArea) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:mobileHeaderBtn];
    
    _areaCodeIdLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 5, 60, 15)];
    _areaCodeIdLabel.text = @"+86";
    _areaCodeIdLabel.font = [UIFont systemFontOfSize:10.0];
    [mobileHeaderBtn addSubview:_areaCodeIdLabel];
    
    _areaLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 15, 60, 15)];
    _areaLabel.font = [UIFont systemFontOfSize:10.0];
    _areaLabel.text = NSLocalizedString(@"China", nil);
    [mobileHeaderBtn addSubview:_areaLabel];
    
    emailHeaderLabel = [[UILabel alloc]initWithFrame:mobileHeaderBtn.frame];
    emailHeaderLabel.text = NSLocalizedString(@"mineEmail", nil);
    emailHeaderLabel.hidden = YES;
    emailHeaderLabel.font = [UIFont systemFontOfSize:13.0];
    [self addSubview:emailHeaderLabel];
    
    //判断默认进来是邮箱还是电话
    if ([validateInputValue validateEmail:[[NSUserDefaults standardUserDefaults] objectForKey:@"userMobile"]])
    {
        emailHeaderLabel.hidden = NO;
        mobileHeaderBtn.hidden = YES;
        mobileBtn.selected = NO;
        emailBtn.selected = YES;
        telePhoneField.keyboardType = UIKeyboardTypeDefault;
        emailString = [[NSUserDefaults standardUserDefaults] objectForKey:@"userMobile"];
    }
    else
    {
        emailHeaderLabel.hidden = YES;
        mobileHeaderBtn.hidden = NO;
        mobileBtn.selected = YES;
        emailBtn.selected = NO;
        telePhoneField.keyboardType = UIKeyboardTypeNumberPad;
        mobileString = [[NSUserDefaults standardUserDefaults] objectForKey:@"userMobile"];
        //如果本地有区号就显示没有就显示中国
        int i = 0;
        for (i = 0; i < AreaCodeArray.count; i ++) {
            NSString * areaCodeString = AreaCodeArray[i];
            if ([areaCodeString isEqualToString:AREACODE]) {
                _areaCodeIdLabel.text = [NSString stringWithFormat:@"+%@",areaCodeString];
                _areaLabel.text = AreaArray[i];
            }
        }
        
    }
    telePhoneField.text = emailString == nil?mobileString:emailString;
    if (telePhoneField.text.length > 0) {
        mobileFlag = YES;
    }
    
    //验证码
    x = 22;
    width = telePhoneField.frame.size.width / 2.0 - x + 40;
    y += height + 5;
    checkTextField = [[UITextField alloc]initWithFrame:CGRectMake(x, y, width, height)];
    checkTextField.placeholder = NSLocalizedString(@"checkNum", nil);
    checkTextField.font = [UIFont systemFontOfSize:13.0];
    checkTextField.borderStyle = UITextBorderStyleNone;
    checkTextField.keyboardType = UIKeyboardTypeNumberPad;
    checkTextField.backgroundColor = [UIColor whiteColor];
    checkTextField.enabled = YES;
    checkTextField.delegate = self;
    checkTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self addSubview:checkTextField];
    
    x = UI_SCREEN_WIDTH - 122;
    width = 100;
    checkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    checkBtn.frame = CGRectMake(x, y, width, height);
    [checkBtn setTitle: NSLocalizedString(@"getCheckNum", nil) forState:0];
    checkBtn.titleLabel.font = [UIFont systemFontOfSize:13.0];
    [checkBtn setBackgroundColor:[UIColor clearColor]];
    checkBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [checkBtn setTitleColor:UIColorFromRGB(0x7dc234) forState:0];
    checkBtn.enabled = YES;
    [checkBtn addTarget:self action:@selector(checkClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:checkBtn];
    
    codeLineView = [[LineView alloc]initWithFrame:CGRectMake(16, y + height, ScreenWidth - 32, 0.5)];
    codeLineView.backgroundColor = UIColorFromRGB(0xc1c1c1);
    [self addSubview:codeLineView];
    
    x = 22;
    y += height + 5;
    width = ScreenWidth - x -16;
    height = 39;
    newPWDTextField = [[UITextField alloc]initWithFrame:CGRectMake(x, y, width, height)];
    newPWDTextField.placeholder = NSLocalizedString(@"newPassWord", nil);
    newPWDTextField.font = [UIFont systemFontOfSize:13.0];
    newPWDTextField.borderStyle = UITextBorderStyleNone;
    newPWDTextField.secureTextEntry = YES;
    newPWDTextField.delegate = self;
    newPWDTextField.backgroundColor = [UIColor whiteColor];
    newPWDTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    newPWDTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [self addSubview:newPWDTextField];
    UIImageView * newSeeImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    newPWDTextField.rightViewMode = UITextFieldViewModeAlways;
    newPWDTextField.rightView = newSeeImgView;
    newSeeImgView.userInteractionEnabled = YES;
    UITapGestureRecognizer * newSeeTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(seeNewTap)];
    [newSeeImgView addGestureRecognizer:newSeeTap];
    newSeeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    newSeeBtn.frame = CGRectMake(18, 14, 16, 12);
    newSeeBtn.selected = NO;
    newSeeBtn.userInteractionEnabled = NO;
    [newSeeBtn setBackgroundImage:[UIImage imageNamed:@"Browse"] forState:UIControlStateNormal];
    [newSeeBtn setBackgroundImage:[UIImage imageNamed:@"GreenBrowse"] forState:UIControlStateSelected];
    [newSeeImgView addSubview:newSeeBtn];
    
    passWordLineView = [[LineView alloc]initWithFrame:CGRectMake(16, y + height, ScreenWidth - 32, 0.5)];
    passWordLineView.backgroundColor = UIColorFromRGB(0xc1c1c1);
    [self addSubview:passWordLineView];
    
//    UIImageView * passWordView = [[UIImageView alloc]initWithFrame:CGRectMake(20, y + 10, 20, 20)];
//    UIImage * passWordImg = [UIImage imageNamed:@"36登录_密码"];
//    passWordView.image = passWordImg;
//    [self addSubview:passWordView];
    
    x = 16;
    y += height + 26;
    width = ScreenWidth - 2 * x;
    height = 48;
    nextBtn = [[UIButton alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [nextBtn setTitleColor:UIColorFromRGBAndA(0xffffff, 0.5) forState:0];
    [nextBtn setTitle:NSLocalizedString(@"makeSureChangePWD", nil) forState:0];
    nextBtn.titleLabel.font = [UIFont systemFontOfSize:19.0];
    nextBtn.layer.cornerRadius = 5;
    nextBtn.layer.masksToBounds = YES;
    nextBtn.enabled = NO;
    [nextBtn setBackgroundColor:UIColorFromRGBAndA(0x7dc234, 0.5)];
    [nextBtn addTarget:self action:@selector(MakeSure) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:nextBtn];
}

#pragma mark ----------点击手机号
-(void)mobileClick
{
    [telePhoneField resignFirstResponder];
    mobileBtn.selected = !mobileBtn.selected;
    if (mobileBtn.selected) {
        emailBtn.selected = NO;
        mobileHeaderBtn.hidden = NO;
        emailHeaderLabel.hidden = YES;
        telePhoneField.keyboardType = UIKeyboardTypeNumberPad;
        telePhoneField.placeholder = NSLocalizedString(@"loginPromt", nil);
    }
    else
    {
        emailBtn.selected = YES;
        emailHeaderLabel.hidden = NO;
        mobileHeaderBtn.hidden = YES;
        telePhoneField.keyboardType = UIKeyboardTypeDefault;
        telePhoneField.placeholder = NSLocalizedString(@"mineEmail", nil);
    }
}


#pragma mark ----------点击邮箱
-(void)emailClick
{
    [telePhoneField resignFirstResponder];
    emailBtn.selected = !emailBtn.selected;
    if (emailBtn.selected) {
        mobileBtn.selected = NO;
        emailHeaderLabel.hidden = NO;
        mobileHeaderBtn.hidden = YES;
        telePhoneField.keyboardType = UIKeyboardTypeDefault;
        telePhoneField.placeholder = NSLocalizedString(@"mineEmail", nil);
    }
    else
    {
        telePhoneField.keyboardType = UIKeyboardTypeNumberPad;
        mobileBtn.selected = YES;
        mobileHeaderBtn.hidden = NO;
        emailHeaderLabel.hidden = YES;
        telePhoneField.placeholder = NSLocalizedString(@"loginPromt", nil);
    }
}


#pragma mark ---------- 改变地区或者国家
-(void)chooseArea
{
    if (_delegate && [_delegate respondsToSelector:@selector(changeArea)]) {
        [_delegate changeArea];
    }
}

#pragma mark --------看密码
-(void)seeNewTap
{
    newSeeBtn.selected = !newSeeBtn.selected;
    if (newSeeBtn.selected) {
        newPWDTextField.secureTextEntry = NO;
    }
    else
    {
        newPWDTextField.secureTextEntry = YES;
    }
}

-(void)checkClick
{
    telePhoneField.text = [telePhoneField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    checkTextField.text = [checkTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    [newPWDTextField resignFirstResponder];
    [checkTextField resignFirstResponder];
    [telePhoneField resignFirstResponder];
    NSMutableDictionary * postDict = [[NSMutableDictionary alloc]init];
    if (emailBtn.selected) {
        if (![validateInputValue validateStringIsNull:telePhoneField.text]) {
            if (![validateInputValue validateEmail:telePhoneField.text]) {
                [PromptInfoView showMessage:NSLocalizedString(@"AccountError", nil)];
                return;
            }
        }
        else
        {
            [PromptInfoView showMessage:NSLocalizedString(@"errorAccount", nil)];
            return;
        }
        [postDict setValue:telePhoneField.text forKey:@"email"];
    }
    else
    {
        if (![validateInputValue validateStringIsNull:telePhoneField.text]) {
            if (![validateInputValue isPureNumandCharacters:telePhoneField.text]) {
                [PromptInfoView showMessage:NSLocalizedString(@"AccountError", nil)];
                return;
            }
        }
        else
        {
            [PromptInfoView showMessage:NSLocalizedString(@"errorAccount", nil)];
            return;
        }
        [postDict setValue:telePhoneField.text forKey:@"mobile"];
        [postDict setValue:[_areaCodeIdLabel.text substringFromIndex:1]forKey:@"areaCode"];
    }
    if (_delegate && [_delegate respondsToSelector:@selector(getCodeData:)]) {
        [_delegate getCodeData:postDict];
    }
}

#pragma mark --------提交前的检测
-(void)MakeSure
{
    [self endEditing:YES];
    telePhoneField.text = [telePhoneField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    checkTextField.text = [checkTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    [newPWDTextField resignFirstResponder];
    [checkTextField resignFirstResponder];
    [telePhoneField resignFirstResponder];
    
    if ([validateInputValue validateStringIsNull:telePhoneField.text]) {
        [PromptInfoView showMessage:NSLocalizedString(@"AccountError", nil)];
        return;
    }
    if (mobileBtn.selected) {
        if (![validateInputValue isPureNumandCharacters:telePhoneField.text]) {
            [PromptInfoView showMessage:NSLocalizedString(@"AccountError", nil)];
            return;
        }
    }
    else if (emailBtn.selected)
    {
        if (![validateInputValue validateEmail:telePhoneField.text]) {
            [PromptInfoView showMessage:NSLocalizedString(@"AccountError", nil)];
            return;
        }
    }
    
    if ([validateInputValue validateStringIsNull:checkTextField.text]) {
        [PromptInfoView showMessage:NSLocalizedString(@"vcodeWrong", nil)];
        return;
    }
    if (![validateInputValue validatePassword:newPWDTextField.text]) {
        [PromptInfoView showMessage:NSLocalizedString(@"loginingPromt", nil)];
        return;
    }
    
    NSString * string = [self getPassword:newPWDTextField.text];
    if ([validateInputValue isPureNumandCharacters:telePhoneField.text]==YES) {
        [self getRestData:string getCodeWay:@"0"];
    }
    else if([validateInputValue validateEmail:telePhoneField.text]==YES)
    {
        [self getRestData:string getCodeWay:@"1"];
    }
}

#pragma mark -------- 加密
-(NSString *)getPassword:(NSString *)password
{
    MyRsa * rsa = [[MyRsa alloc]init];
    if (rsa != nil) {
        NSString * encryptPWD = [rsa RSAEncrypotoTheData:[NSString stringWithFormat:@"12345678%@",password] key:publicKeyString];
        encryptPWD = [encryptPWD stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        return encryptPWD;
    }
    else
        return nil;
    
}


//重置密码的网络请求
-(void)getRestData:(NSString *)pwd getCodeWay:(NSString *)getCodeWay//获取验证码的方式
{
    NSMutableDictionary * postDict = [[NSMutableDictionary alloc]init];
    if([@"0" isEqualToString:getCodeWay]==YES)
    {
        [postDict setValue:telePhoneField.text forKey:@"mobile"];
        [postDict setValue:[_areaCodeIdLabel.text substringFromIndex:1] forKey:@"areaCode"];
    }
    else if ([@"1" isEqualToString:getCodeWay]==YES)
    {
        [postDict setValue:telePhoneField.text forKey:@"email"];
    }
    [postDict setValue:checkTextField.text forKey:@"authCode"];
    [postDict setValue:pwd forKey:@"passwd"];
    
    if (_delegate && [_delegate respondsToSelector:@selector(postPassword:)]) {
        [_delegate postPassword:postDict];
    }
}


#pragma mark ------------textFieldDelegate
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField == telePhoneField) {
        telePhoneLineView.backgroundColor = UIColorFromRGB(0x7dc234);
        checkTextField.enabled = YES;
        checkBtn.enabled = YES;
        [checkBtn setTitleColor:UIColorFromRGB(0x7dc234) forState:0];
    }
    else if(textField == newPWDTextField)
    {
        passWordLineView.backgroundColor = UIColorFromRGB(0x7dc234);
    }
    else if (textField == checkTextField)
    {
        codeLineView.backgroundColor = UIColorFromRGB(0x7dc234);
    }
}


-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField == telePhoneField) {
        telePhoneLineView.backgroundColor = UIColorFromRGB(0xc1c1c1);
        telePhoneField.text = textField.text;
    }
    else if (textField == newPWDTextField)
    {
        passWordLineView.backgroundColor = UIColorFromRGB(0xc1c1c1);
        newPWDTextField.text = textField.text;
    }
    else if(textField == checkTextField)
    {
       codeLineView.backgroundColor = UIColorFromRGB(0xc1c1c1);
        checkTextField.text = textField.text;
    }
}

-(BOOL)textFieldShouldClear:(UITextField *)textField
{
    if (textField == telePhoneField) {
        mobileFlag = NO;
    }
    else if (textField == checkTextField)
    {
        codeFlag = NO;
    }
    else if (textField == newPWDTextField)
    {
        passwordFlag = NO;
    }
    [self canTapOfRegist];
    return YES;
}

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
     NSString * newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
    if (textField == telePhoneField) {
        if (newString.length > 0) {
            mobileFlag = YES;
        }
        else
        {
            mobileFlag = NO;
        }
    }
    else if (textField == checkTextField)
    {
        if (newString.length > 0) {
            codeFlag = YES;
        }
        else
        {
            codeFlag = NO;
        }
    }
    else if (textField == newPWDTextField)
    {
        if (newString.length > 0) {
            passwordFlag = YES;
        }
        else
        {
            passwordFlag = NO;
        }
    }
    [self canTapOfRegist];
    return YES;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

#pragma mark -------- 成功获取验证
-(void)getCodeSuccess
{
      _time = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
}

//启动定时器
-(void)updateTime
{
    count ++;
    if (count >= 60) {
        if ([_time isValid]) {
            [_time invalidate];
            _time = nil;
            count = 0;
        }
        [checkBtn setTitle:NSLocalizedString(@"getCheckNum", nil) forState:0];
        checkBtn.userInteractionEnabled = YES;
        return;
    }
    else
    {
        checkBtn.userInteractionEnabled = NO;
    }
    NSString * fisrtString = NSLocalizedString(@"timePromt", nil) ;
    NSString * lastString = NSLocalizedString(@"timePromtLast", nil);
    [checkBtn setTitle:[NSString stringWithFormat:@"%@%d%@",fisrtString,(60 - count),lastString] forState:0];
}


#pragma mark ----------- 判断注册按钮是否能够点击
-(void)canTapOfRegist
{
    if (mobileFlag && codeFlag && passwordFlag) {
        [self nextBtnEnable];
    }
    else
    {
        [self nextBtnDisenable];
    }
}


#pragma mark ----------注册按钮点击和不可以点击的两种状态
-(void)nextBtnEnable
{
    [nextBtn setBackgroundColor:UIColorFromRGB(0x7cd234)];
    [nextBtn setTitleColor:UIColorFromRGB(0xffffff) forState:0];
    nextBtn.enabled = YES;
}

-(void)nextBtnDisenable
{
    [nextBtn setBackgroundColor:UIColorFromRGBAndA(0x7cd234, 0.5)];
    [nextBtn setTitleColor:UIColorFromRGBAndA(0xffffff,0.5) forState:0];
    nextBtn.enabled = NO;
}


-(void)hiddenKeyboard
{
    [telePhoneField resignFirstResponder];
    [checkTextField resignFirstResponder];
    [newPWDTextField resignFirstResponder];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
